package com.vates.vsp.practico.alumnos.business;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import com.vates.vsp.practico.alumnos.service.AlumnoService;
import com.vates.vsp.practico.alumnos.view.AlumnoView;

/**
 * 
 * @author scerrato
 * @since 27/10/2010 Capa de Negocio
 */
@ManagedBean(name = "alumnoListener")
@SessionScoped
public class AlumnoListener {

	@ManagedProperty(value = "#{alumnoView}")
	AlumnoView alumnoView;
	@ManagedProperty(value = "#{alumnoService}")
	AlumnoService alumnoService;

	public AlumnoView getAlumnoView() {
		return alumnoView;
	}

	public void setAlumnoView(AlumnoView alumnoView) {
		this.alumnoView = alumnoView;
	}

	public AlumnoService getAlumnoService() {
		return alumnoService;
	}

	public void setAlumnoService(AlumnoService alumnoService) {
		this.alumnoService = alumnoService;
	}

	public String volver() {
		return "volver";
	}

	public String salir() {
		return "salir";
	}

	public String guardar() {
		try {
			alumnoService.guardarAlumno(alumnoView.getAlumno());
			return "guardar-ok";
		} catch (Exception e) {
			return "error";
		}
	}
}
